package com.xbongbong.saas.domain.dao;

import com.xbongbong.saas.domain.entity.ProductSerialFlowEntity;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * (TbSaasProductSerialFlow)表数据库访问层
 *
 * @author makejava
 * @since 2020-05-19 13:43:36
 */
public interface ProductSerialFlowDao {

    /**
     * 新增数据
     *
     * @param productSerialFlow 实例对象
     * @return 影响行数
     */
    int insert(ProductSerialFlowEntity productSerialFlow);

    /**
     * 修改数据
     *
     * @param productSerialFlow 实例对象
     * @return 影响行数
     */
    int update(ProductSerialFlowEntity productSerialFlow);

    Integer getEntitysCount(@Param("param") Map<String, Object> param);

    List<ProductSerialFlowEntity> findEntitys(@Param("param") Map<String, Object> param);

    void insertBatch(@Param("list") List<ProductSerialFlowEntity> productSerialFlowEntitys);

    /**
     * 批量删除
     *
     * @param refIdIn                关联单据id
     * @param corpid                 公司id
     * @param businessType
     * @param enableSerialProductIds
     * @return 删除记录数
     */
    Integer deleteBatch(@Param("refIdIn") List<Long> refIdIn, @Param("corpid") String corpid, @Param("businessType") Integer businessType, @Param("productIdIn") List<Long> enableSerialProductIds);
    /**
     * 批量删除
     *
     * @param idIn                id
     * @param corpid                 公司id
     * @return 删除记录数
     */
    Integer deleteBatchById(@Param("idIn") List<Long> idIn, @Param("corpid") String corpid);
    /**
     * 获取序列号最近时间的流水记录
     *
     * @param corpid 公司id
     * @param seqKey 序列号
     * @param refId
     * @return ProductSerialBalanceEntity
     */
    ProductSerialFlowEntity getLastSerialFlow(@Param("corpid") String corpid, @Param("seqKey") String seqKey, @Param("refId") Long refId);

    void delByRefProductAndBusinessType(@Param("corpid") String corpid, @Param("refProductId") Long refProductId, @Param("businessType") int businessType);

    List<ProductSerialFlowEntity> getBySeqKey(@Param("seqKey") String seqKey, @Param("corpid") String corpid);

    List<ProductSerialFlowEntity> getFlowByRefIdAndBusiness(@Param("refIdIn") List<Long> refIdIn, @Param("businessType") Integer businessType, @Param("corpid") String corpid);

    /**
     * 批量更新seq 和 memo
     * @param updateSerialFlowList
     * @param corpid
     * @return java.lang.Integer
     * @author 吴峰
     * @date 2022/2/28 11:11
     */
    Integer updateBatch(@Param("list") List<ProductSerialFlowEntity> updateSerialFlowList,@Param("corpid") String corpid);

    /**
     *
     * @param corpid
     * @param refId
     * @param refProductIdIn
     * @param businessType
     * @return
     */
    Integer deleteByRefProductId(@Param("corpid") String corpid, @Param("refId") Long refId, @Param("refProductIdIn") Collection<Long> refProductIdIn, @Param("businessType") Integer businessType);

    List<ProductSerialFlowEntity> getLastSerialFlowByProductId(@Param("param") Map<String, Object> param);
}